#pragma once


#include <memory>
#include "Containers/Containers.h" 

#include "ScriptCompiler/Description/VariableDescription.h"

#include "ScriptCompiler/AST/SentenceBlockNode.h"

class IFrameOperation;

class CFunctionBodyDescription 
{
public:
    // might be nullptr for auto generated function body
    std::shared_ptr<CSentenceBlockNode> ASTNode;

    void AddOperation(std::shared_ptr<IFrameOperation> InOperation);

    //void InsertOperationAfter(std::shared_ptr<IFrameOperation> InOperation, uint32_t Index);

    //insert InNewOperation after InAfterOperation
    void InsertOperationAfter(std::shared_ptr<IFrameOperation> InNewOperation
        , std::shared_ptr<IFrameOperation> InAfterOperation);

    //insert InNewOperation before InBeforeOperation
    void InsertOperationBefore(std::shared_ptr<IFrameOperation> InNewOperation
        , std::shared_ptr<IFrameOperation> InBeforeOperation);

    void RemoveOperation(std::shared_ptr<IFrameOperation> InOperation);

    TVector<std::shared_ptr<IFrameOperation>> RemoveOperations(
        std::shared_ptr<IFrameOperation> RangeBegin
        , std::shared_ptr<IFrameOperation> RangeEnd);

    //remove InOperation and operations after InOperation
    //return removed operations
    TVector<std::shared_ptr<IFrameOperation>> RemoveOperationAndAfter(
        std::shared_ptr<IFrameOperation> InOperation);

    //remove  operations after InOperation
    //return removed operations
    TVector<std::shared_ptr<IFrameOperation>> RemoveAfter(
        std::shared_ptr<IFrameOperation> InOperation);

    const TVector<std::shared_ptr<IFrameOperation>> & GetOperations()
    {
        return Operations;
    }
protected:
    TVector<std::shared_ptr<IFrameOperation>> Operations;

public:
    void AddLocalVariable(std::shared_ptr<CVariableDescription> InVariable);
   
    TVector<std::shared_ptr<CVariableDescription>> LocalVariables;

};